#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;
const int N = 2e5 + 10;
const LL INF = 1e9;

struct Seg
{
    LL pos, k;
    bool operator<(const Seg& W)const{
        return pos < W.pos;
    }   
};
LL X[N], P[N], d[N * 3];
vector<Seg> v;
LL n, m;
LL mx, mi;

void upd(LL id, LL val){
    if (val <= m)return;
    mx = max(mx, id + val - m);
    mi = min(mi, id - val + m);
}

void solve(){
    memset(d, 0, sizeof d);
    v.clear();
    scanf("%d%d", &n, &m);

    LL x, p;
    for(int i = 1; i <= n; i ++){
        scanf("%d%d", &X[i], &P[i]);
        v.push_back({X[i] - P[i] + 1, 1});
        v.push_back({X[i] + 1, -2});
        v.push_back({X[i] + P[i] + 1, 1});
    }

    mx = -INF, mi = INF;
    LL pre = 0;
    v.push_back({-INF, 0});
    v.push_back({INF, 0});
    sort(v.begin(), v.end());
    for(int i = 1; i < v.size() - 1; i ++){
        d[i] = d[i - 1] + v[i].k;
        if(v[i].pos != v[i + 1].pos){
            upd(v[i].pos, pre + d[i]);
            upd(v[i + 1].pos - 1, (LL)pre + (LL)d[i] * (v[i + 1].pos - v[i].pos));
        }
        pre = pre + d[i] * (v[i + 1].pos - v[i].pos);
    }

    for (int i = 1; i <= n; i++) {
        if ((X[i] + P[i]) >= mx && (X[i] - P[i]) <= mi)printf("1");
        else printf("0");
    }
    printf("\n");
}

int main(){ 
    int T;
    scanf("%d", &T);

    while(T--){
        solve();
    }

    return 0;
}





